package com.example.barcodeapp.ui.wode.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.barcodeapp.R;
import com.example.barcodeapp.base.BaseActivity;
import com.example.barcodeapp.common.Constants;
import com.example.barcodeapp.interfaces.own.IOwn;
import com.example.barcodeapp.persenter.own.DingDanXiangQingPresenter;
import com.example.barcodeapp.ui.wode.bean.DingDanXiangQingBean;


public class ParticularsActivity extends BaseActivity<IOwn.DingDanXiangQingPresenter> implements IOwn.DingDanXiangQingView {

    private TextView mTvType;
    private TextView mTvDingDanNumber;
    private TextView mTvRiQi;
    private TextView mTvName1;
    private TextView mTvScore;
    private TextView mTvNumber;
    private TextView mTvZhongJia;
    private TextView mTvYouHuiQuan;
    private TextView mTvDingDanZhongJia;
    private ImageView mIvParticularsImg;
    private String dingdanbiaohao;

    @Override
    protected int getLayout() {
        return R.layout.activity_particulars;
    }

    @Override
    protected void initView() {
        Intent intent = getIntent();
        dingdanbiaohao = intent.getStringExtra("ddnum");
        mTvType = findViewById(R.id.tv_type);
        mTvDingDanNumber = findViewById(R.id.tv_dingdannumber);
        mTvRiQi = findViewById(R.id.tv_riqi);
        mTvName1 = findViewById(R.id.tv_name1);
        mTvScore = findViewById(R.id.tv_score);
        mTvNumber = findViewById(R.id.tv_number);
        mTvDingDanZhongJia = findViewById(R.id.tv_dingdanzhongjia);
        mTvYouHuiQuan = findViewById(R.id.tv_youhuiquan);
        mTvZhongJia = findViewById(R.id.tv_zhongjia);
        mIvParticularsImg = findViewById(R.id.particulars_img1);
    }

    @Override
    protected DingDanXiangQingPresenter initPersenter() {
        return new DingDanXiangQingPresenter();
    }

    @Override
    protected void initData() {
        persenter.getDingDanXiangQing(dingdanbiaohao);
    }

    @Override
    public void getDingDanXiangQingBean(DingDanXiangQingBean dingDanXiangQingBean) {
        DingDanXiangQingBean.DataBean data = dingDanXiangQingBean.getData();
        mTvNumber.setText("X" + data.getNum());//订单数量
        mTvName1.setText(data.getName());//订单名称
        Glide.with(this).load(Constants.Base_TPUrl + data.getFengmian()).into(mIvParticularsImg);
        mTvYouHuiQuan.setText(" - ￥ " + data.getUseYouhuiquanDiKouPrice());
        mTvDingDanZhongJia.setText("￥ " + data.getShijiprice());
        mTvZhongJia.setText("￥ " + data.getPrice());
        mTvRiQi.setText(data.getPaytime());
        mTvDingDanNumber.setText(data.getDdnum());
        int state = data.getState();
        if (state == 1) {
            mTvType.setText("去支付");
        } else if (state == 2) {
            mTvType.setText("已完成");
        } else if (state == 3) {
            mTvType.setText("去支付");
        }
    }
}
